home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3676 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  32 lines

  1. Newsgroups: comp.lang.c
  2. Path: usenet.eel.ufl.edu!warwick!bsmail!talisker!nathan
  3. From: nathan@pact.srf.ac.uk (Nathan Sidwell)
  4. Subject: Re: division problem
  5. Message-ID: <DLzvGG.2rn@uns.bris.ac.uk>
  6. Sender: usenet@uns.bris.ac.uk (Usenet news owner)
  7. Nntp-Posting-Host: talisker.pact.srf.ac.uk
  8. Organization: Inmos
  9. X-Newsreader: TIN [version 1.2 PL2]
  10. References: <31097D77.11AA@rain.org> <26JAN199622082450@erich.triumf.ca> <4eh246$u6h@airdmhor.gen.nz> <4ej4ha$66@fountain.mindlink.net>
  11. Date: Tue, 30 Jan 1996 12:45:52 GMT
  12.  
  13. Gene Wirchenko (genew@mindlink.bc.ca) wrote:
  14. : gumboot@airdmhor.gen.nz (Simon Hosie) wrote:
  15.  
  16. : >celcius = (fahrenheit - 32) * 5 / 9;
  17.  
  18. :      That's disgusting <g> as it doesn't round.  Try it with 39 deg F:
  19. :           (39-32)*5/9 ::= 7*5/9 ::= 35/9 ::= 3
  20. : but the actual value is 3.8... i.e. nearly 4.  If you must int, 4
  21. : would be a better answer.
  22.  
  23. Still no need to use floating point,
  24. celcius = ((fahrenheit - 32) * 5 + 4) / 9
  25.  
  26. nathan
  27. --
  28. Nathan Sidwell                         Holder of the Xmris home page
  29. Chameleon Architecture Group at SGS-Thomson, formerly Inmos
  30. http://www.pact.srf.ac.uk/~nathan/                  Tel 0117 9707182
  31. nathan@inmos.co.uk or nathan@bristol.st.com or nathan@pact.srf.ac.uk
  32.